package rush.edu.wechat.service.user;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;

import java.util.concurrent.CountDownLatch;

/**
 * DESC:Dubbo main 方式启动
 * USER:hmily
 * DATE:2018/2/1
 * TIME:11:17
 */
@EnableConfigurationProperties
@SpringBootApplication
@ComponentScan(basePackages = "rush.edu.wechat")
public class DubboLoader {

    private static final Logger logger = LoggerFactory.getLogger(DubboLoader.class);

    @Bean
    public CountDownLatch closeLatch() {
        return new CountDownLatch(1);
    }

    public static void main(String[] args) throws InterruptedException {

        ApplicationContext ctx = new SpringApplicationBuilder()
                .sources(DubboLoader.class)
                .web(false)
                .run(args);

        logger.info("项目启动!");

        CountDownLatch closeLatch = ctx.getBean(CountDownLatch.class);
        closeLatch.await();
    }
}
